﻿using CKS.PLC.Action.System;
using FreeSql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.Models.ProductionControl;

namespace CKS.PLC.Action.Subscription
{
    public class ActionTask : SaveProcessingResults
    {
        public ActionTask(DecodeValue _value) : base(_value)
        {
        }

        public override void AfterSaved(CksCollected mainRecord)
        {
            string code = Value.GetLocationData(mainRecord.LocationId, 1).ToString();
            int tagId = Value.Position.LocationId;
            int plcid = Value.Position.PlcId;
            CksCMMProduct product = new CksCMMProduct()
            {
                ProductId = code,
                DeviceId = tagId,
                LineId = plcid,
            };
            conn.Insert<CksCMMProduct>(product).ExecuteIdentity();
        }
    }
}